import logging


def get_logger(name='test_logger'):
    logger = logging.getLogger(name)
    if not logger.handlers:
        # 设置日志格式
        fmt = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
        # 文件
        file_hd = logging.FileHandler(r'C:\Users\20176\Desktop\yue_mo\logs\rizhi.log', encoding='utf-8')
        file_hd.setFormatter(fmt)
        logger.addHandler(file_hd)
        # 控制台
        kong_hd = logging.StreamHandler()
        kong_hd.setFormatter(fmt)
        logger.addHandler(kong_hd)
        # 设置日志级别
        logger.setLevel(logging.INFO)
    return logger
